<template>
	<view>
		<view class="content">
			<view class="li">
				<view class="li_1">
					昵称
				</view>
				<input v-model="name" type="text" value="" placeholder="请输入昵称"/>
			</view>
			<view class="queding" @click="queding">
				<view>
					确定
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {editUser,login} from '@/request/api.js'
	export default {
		data() {
			return {
				name:'',
				user:''
			}
		},
		onLoad() {
			let that  = this
			that.user = uni.getStorageSync('regionMessage');
			that.name=that.user.nickname
		},
		methods: {
			login1(){
				let a = uni.getStorageSync('mobile')
				let b = uni.getStorageSync('password')
				console.log(a,b)
				let data={
					account:a,
					password:b,
					type:1
				}
				login(data).then(res=>{
					console.log(res,"登录登录")
					uni.setStorageSync('regionMessage',res.data)
					setTimeout(function(){
						uni.navigateBack({
							delta:1
						})
					},600)
				}).catch(err=>{
					
				})
			},
			queding(){
				let that = this
				let data={
					user_id:that.user.id,
					nickname:that.name
				}
				editUser(data).then(res=>{
					uni.showToast({
						title:'修改成功',
						icon:'none'
					})
					that.login1()
					
				}).catch(err=>{
					
				})
			}
		}
	}
</script>

<style  lang="scss">
	.queding{
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 200rpx;
		view{
			width: 340rpx;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 1000px;
			background: #1855F6;
			font-size: 30rpx;
			color: #fff;
			text-align: center;
		}
	}
	.li{
		padding: 33rpx 40rpx;
		display: flex;
		align-items: center;
		border-top: 1px solid rgba(211, 213, 220, 0.4);
		border-bottom: 1px solid rgba(211, 213, 220, 0.4);
		.li_1{
			width: 220rpx;
		}
	}
	
</style>
